﻿// ***********************************************************************
// Apache 2.0 License
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR 
// PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
//
// See the Apache Version 2.0 License for specific language governing
// permissions and limitations under the License.
// ***********************************************************************
// Assembly  : ContractMeow.Api.Dtos
// File      : AutoCompleteResults.cs
//
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;

namespace ContractMeow.Api.Dtos
{
	/// <summary>
	/// Class AutoCompleteResults
	/// </summary>
	public sealed class AutoCompleteResults : IAutoCompleteResults
	{
		#region Private Variables
		/// <summary>
		/// The instance Id
		/// </summary>
		private readonly long _id;

		#endregion

		/// <summary>
		/// Initializes a new instance of the <see cref="AutoCompleteResults" /> class.
		/// </summary>
		public AutoCompleteResults(string prefixQuery)
		{
			PrefixQuery = prefixQuery;
			_id = PrefixQuery.GetHashCode();
		}

		/// <summary>
		/// Gets or sets the id.
		/// </summary>
		/// <value>The id.</value>
		public long Id
		{
			get { return _id; }
		}

		public string PrefixQuery { get; private set; }

		/// <summary>
		/// Gets the has groups.
		/// </summary>
		/// <value>The has groups.</value>
		public Boolean HasGroups
		{
			get { return Groups != null && Groups.Any(); }
		}

		/// <summary>
		/// Gets the has open graphs.
		/// </summary>
		/// <value>The has open graphs.</value>
		public Boolean HasOpenGraphs
		{
			get { return OpenGraphs != null && OpenGraphs.Any(); }
		}

		/// <summary>
		/// Gets the has topics.
		/// </summary>
		/// <value>The has topics.</value>
		public Boolean HasTopics
		{
			get { return Topics != null && Topics.Any(); }
		}

		/// <summary>
		/// Gets the has users.
		/// </summary>
		/// <value>The has users.</value>
		public Boolean HasUsers
		{
			get { return Users != null && Users.Any(); }
		}

		/// <summary>
		/// Gets the has all.
		/// </summary>
		/// <value>The has all.</value>
		public Boolean HasAll
		{
			get { return HasGroups && HasOpenGraphs && HasTopics && HasUsers; }
		}

		/// <summary>
		/// Gets or sets the groups.
		/// </summary>
		/// <value>The groups.</value>
		public IList<IAutoCompleteValueEx> Groups { get; set; }

		/// <summary>
		/// Gets or sets the open graphs.
		/// </summary>
		/// <value>The open graphs.</value>
		public IList<IAutoCompleteValue> OpenGraphs { get; set; }

		/// <summary>
		/// Gets or sets the topics.
		/// </summary>
		/// <value>The topics.</value>
		public IList<IAutoCompleteValue> Topics { get; set; }

		/// <summary>
		/// Gets or sets the users.
		/// </summary>
		/// <value>The users.</value>
		public IList<IAutoCompleteValueEx> Users { get; set; }
	}
}